
package pri.syl.xiaowu.websocket.netty.server.thread;


import pri.syl.xiaowu.websocket.core.template.WebsocketChannelTemplate;
import pri.syl.xiaowu.websocket.core.template.WebsocketRouteTemplate;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:27
 * @Description 业务抽象线程
 **/
@Getter
@Setter
public abstract class AbstractWebsocketServerBusinessThread implements Runnable {
    private WebsocketRouteTemplate websocketRouteTemplate;
    private WebsocketChannelTemplate websocketChannelTemplate;
    private WebSocketFrame webSocketFrame;

    public AbstractWebsocketServerBusinessThread(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate, WebSocketFrame webSocketFrame) {
        this.websocketRouteTemplate = websocketRouteTemplate;
        this.websocketChannelTemplate = websocketChannelTemplate;
        this.webSocketFrame = webSocketFrame;
    }

    /**
     * businessExecution
     *
     * @param websocketRouteTemplate   websocketRouteTemplate
     * @param websocketChannelTemplate websocketChannelTemplate
     * @param webSocketFrame           webSocketFrame
     */
    protected abstract void businessExecution(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate, WebSocketFrame webSocketFrame);

    @Override
    public void run() {
        businessExecution(this.websocketRouteTemplate,
                this.websocketChannelTemplate,
                this.webSocketFrame);
    }
}
